import uniRequest from "./request.js"


const $api = {
		// 登录接口
		login(params,success,fail, complete) {
			return uniRequest.login('core/user/Login',params, success, fail, complete)
		},
		// 退出登录接口
		logOut(success,fail, complete) {
			return uniRequest.requestAjax('core/user/Logout', '', 'GET', success, fail, complete)
		},
		// session续时
		heartBeat(success,fail, complete) {
			return uniRequest.requestAjax('core/user/HeartBeat', '', 'GET', success, fail, complete)
		},
		// 获取用户信息
		getUserInfo(success,fail, complete) {
			return uniRequest.requestAjax('core/user/GetCurUser', '', 'GET', success, fail, complete)
		},
		// 获取工单列表页
		getTickData(params, success, fail, complete){
			return uniRequest.requestAjax('em/wo/GetPMWOList', params, 'GET', success, fail, complete)
		},
		// 开启工单
		startTick(params, success, fail, complete){
			return uniRequest.requestAjax('em/wo/SaveExecWO', params, 'GET', success, fail, complete)
		},
		// 获取点检工单详情页
		getTickList(params, success, fail, complete) {
			return uniRequest.requestAjax('em/wo/GetWOOne', params, 'GET', success, fail, complete)
		},
		// 获取点检工单详情页
		getTickPeopleList(params, success, fail, complete) {
			return uniRequest.requestAjax('core/user/GetByKey', params, 'GET', success, fail, complete)
		},
		//  工单暂存/提交
		temporaryData(params, success, fail, complete) {
			return uniRequest.requestAjax('em/wo/SaveWOOne', params, 'POST', success, fail, complete)
		},
		// 上传图片
		imageUpload(params, name, formData, success, fail, complete) {
			return uniRequest.uploadFile('core/file/upload', params,  name, formData, success, fail, complete)
		},
		// 删除图片
		deleteImage(params, success, fail, complete) {
			return uniRequest.requestAjax('core/file/Delete', params, 'GET', success, fail, complete)
		},
		// 获取消息列表
		getMessageList(params, success, fail, complete) {
			return uniRequest.requestAjax('fac/message/PushAll', params, 'GET', success, fail, complete)
		},
		// 读取消息
		readOne(params, success, fail, complete) {
			return uniRequest.requestAjax('fac/message/ReadOne', params, 'GET', success, fail, complete)
		},
		// 获取故障工单列表
		getFaultTickList(params, success, fail, complete) {
			return uniRequest.requestAjax('em/wo/GetFaultList', params, 'GET', success, fail, complete)
		},
		// 获取故障工单列表
		getFaultOne(params, success, fail, complete) {
			return uniRequest.requestAjax('em/wo/GetFaultOne', params, 'GET', success, fail, complete)
		},
		// 获取设备信息（层级）
		getEqList(params, success, fail, complete) {
			return uniRequest.requestAjax('em/wo/GetEqListByPID', params, 'GET', success, fail, complete)
		},
		// 获取工单优先级列表
		getDicByType(params, success, fail, complete) {
			return uniRequest.requestAjax('core/dic/GetDicByType', params, 'GET', success, fail, complete)
		},
		//  故障保存
		saveFaultOne(params, success, fail, complete) {
			return uniRequest.requestAjax('em/wo/SaveFaultOne', params, 'POST', success, fail, complete)
		},
		// 修改密码
		changePassword(params, success, fail, complete) {
			return uniRequest.requestAjax('core/user/ChangePwd', params, 'POST', success, fail, complete)
		},
		// 扫描获取工单列表
		getWOByQR(params, success, fail, complete) {
			return uniRequest.requestAjax('em/wo/GetWOByQR', params, 'GET', success, fail, complete)
		},
		// 扫描获取设备信息
		getEqInfoByQR(params, success, fail, complete) {
			return uniRequest.requestAjax('em/wo/GetEqInfoByQR', params, 'GET', success, fail, complete)
		},
		// 扫描获取设备履历
		getWOHistoryByQR(params, success, fail, complete) {
			return uniRequest.requestAjax('em/wo/GetWOHistoryByQR', params, 'GET', success, fail, complete)
		},
		// 首页
		getHomeNorm(success, fail, complete) {
			return uniRequest.requestAjax('pa/app/GetHomeNorm', '', 'GET', success, fail, complete)
		},
		// 缺陷录入页面加载
		getCfgByPointCode(params, success, fail, complete) {
			return uniRequest.requestAjax('QM/DefectInput/GetCfgByPointCode', params, 'GET', success, fail, complete)
		},
		// 缺陷录入页面轮型选择后获取模具号
		getMouldByModel(params, success, fail, complete) {
			return uniRequest.requestAjax('qm/DefectInput/GetMouldByModel', params, 'GET', success, fail, complete)
		},
		// 首页报表
		getProduct(params, success, fail, complete) {
			return uniRequest.requestAjax('pa/app/GetProductRpt', params, 'GET', success, fail, complete)
		},
		// 首页成品率报表
		getProductYield(params, success, fail, complete) {
			return uniRequest.requestAjax('pa/app/GetProductYield', params, 'GET', success, fail, complete)
		},
		// 投入量总查询
		getInputTotal(params, success, fail, complete) {
			return uniRequest.requestAjax('pa/app/GetInputTotal', params, 'GET', success, fail, complete)
		},
		//不合格品--获取工序列表
		getAll(params, success, fail, complete) {
			return uniRequest.requestAjax('Fac/Process/GetAll', params, 'GET', success, fail, complete)
		},
		//不合格品--获取缺陷类型列表
		getDefectType(params, success, fail, complete) {
			return uniRequest.requestAjax('QM/DefectManage/GetDefectType', params, 'GET', success, fail, complete)
		},
		//不合格品--获取不合格品
		getDefectQty(params, success, fail, complete) {
			return uniRequest.requestAjax('pa/app/GetDefectQty', params, 'GET', success, fail, complete)
		},
		//不合格品显示饼图
		getDefectPie(params, success, fail, complete) {
			return uniRequest.requestAjax('pa/app/GetDefectPie', params, 'GET', success, fail, complete)
		},
		//模具产量查询
		getMoldOutput(params, success, fail, complete) {
			return uniRequest.requestAjax('pa/app/GetMoldOutput', params, 'GET', success, fail, complete)
		},
		//X光统计
		getXRaySummary(params, success, fail, complete) {
			return uniRequest.requestAjax('pa/app/GetXRaySummary', params, 'GET', success, fail, complete)
		},
		//缺陷保存
		saveData(params, success, fail, complete) {
			return uniRequest.requestAjax('qm/DefectInput/SaveData', params, 'POST', success, fail, complete)
		},
		//获取工序列表
		getAllProcess( success, fail, complete) {
			return uniRequest.requestAjax('fac/Process/GetAll', '', 'GET', success, fail, complete)
		},
		//获取录入点列表
		getAllInputPoint( success, fail, complete) {
			return uniRequest.requestAjax('qm/DefectInput/GetAllInputPoint', '', 'GET', success, fail, complete)
		},
		//获取班次列表
		getAllShiftTime( success, fail, complete) {
			return uniRequest.requestAjax('fac/ShiftTime/GetAll', '', 'GET', success, fail, complete)
		},
		//缺陷查询接口
		getDefectList(params, success, fail, complete) {
			return uniRequest.requestAjax('pa/app/GetDefectList', params, 'GET', success, fail, complete)
		},
		//缺陷工单删除
		deleteByID(params, success, fail, complete) {
			return uniRequest.requestAjax('QM/DefectInput/DeleteByID', params, 'GET', success, fail, complete)
		},
		//获取投入产出
		getProductQtyList(params, success, fail, complete) {
			return uniRequest.requestAjax('pa/app/GetProductQtyList', params, 'GET', success, fail, complete)
		},
		//获取产线
		getEqLineByEqType(params, success, fail, complete) {
			return uniRequest.requestAjax('fac/Plant/GetEqLineByEqType', params, 'GET', success, fail, complete)
		},
		//获取设备
		getEqByEqType(params, success, fail, complete) {
			return uniRequest.requestAjax('fac/Plant/GetEqByEqType', params, 'GET', success, fail, complete)
		},
		//获取轮型
		getAllModel(success, fail, complete) {
			return uniRequest.requestAjax('fac/Model/GetAll', '', 'GET', success, fail, complete)
		},
		//在制品总查询
		getWIPSummary(params,success, fail, complete) {
			return uniRequest.requestAjax('pa/app/GetWIPSummary', params, 'GET', success, fail, complete)
		},
		//绑定用户CID
		bindCID(params,success, fail, complete) {
			return uniRequest.requestAjax('fac/message/BindCID', params, 'GET', success, fail, complete)
		},
		//解除绑定用户CID
		unBindCID(params,success, fail, complete) {
			return uniRequest.requestAjax('fac/message/UnBindCID', params, 'GET', success, fail, complete)
		},
		//工单完成率报表
		getWOCompletionRate(params,success, fail, complete) {
			return uniRequest.requestAjax('em/EqReport/GetWOCompletionRate', params, 'GET', success, fail, complete)
		},
		//群组完成率报表
		getRoleCompletionRate(params,success, fail, complete) {
			return uniRequest.requestAjax('em/EqReport/GetRoleCompletionRate', params, 'GET', success, fail, complete)
		},
		//版本更新
		getUpdataApp(params, success, fail, complete) {
			return uniRequest.requestAjax('pa/app/GetLastVersion', params, 'GET', success, fail, complete)
		},
		//工单取消
		cancelWorkOrder(params, success, fail, complete) {
			return uniRequest.requestAjax('em/wo/CancelWO', params, 'GET', success, fail, complete)
		},
		//获取停机原因列表
		getShutdown(params, success, fail, complete) {
			return uniRequest.requestAjax('core/dic/GetDicByType', params, 'GET', success, fail, complete)
		},
		idSetter:(name,id)=>{
			uni.setStorage({
				key: name,
				data: id,
				success: function () {
					console.log('success');
				}
			});
		},
		idGetter:(name)=>{
			uni.getStorage({
				key: name,
				success: function (res) {
					console.log(res.data);
				}
			});
		},
		getNowFormatDate() {
			let date = new Date();
			let seperator1 = "-";
			let year = date.getFullYear();
			let month = date.getMonth() + 1;
			let strDate = date.getDate();
			if (month >= 1 && month <= 9) {
				month = "0" + month;
			}
			if (strDate >= 0 && strDate <= 9) {
				strDate = "0" + strDate;
			}
			let currentdate = year + seperator1 + month + seperator1 + strDate;
			return currentdate;
		},
		getPreFormatDate() {
			let date = new Date();
			let preDate = new Date(date.getTime() - 24*60*60*1000); //前一天
			let seperator1 = "-";
			let year = preDate.getFullYear();
			let month = preDate.getMonth() + 1;
			let strDate = preDate.getDate();
			if (month >= 1 && month <= 9) {
				month = "0" + month;
			}
			if (strDate >= 0 && strDate <= 9) {
				strDate = "0" + strDate;
			}
			let currentdate = year + seperator1 + month + seperator1 + strDate;
			return currentdate;
		},
		getNextFormatDate() {
			let date = new Date();
			let nextDate = new Date(date.getTime() + 24*60*60*1000); //后一天
			let seperator1 = "-";
			let year = nextDate.getFullYear();
			let month = nextDate.getMonth() + 1;
			let strDate = nextDate.getDate();
			if (month >= 1 && month <= 9) {
				month = "0" + month;
			}
			if (strDate >= 0 && strDate <= 9) {
				strDate = "0" + strDate;
			}
			let currentdate = year + seperator1 + month + seperator1 + strDate;
			return currentdate;
		},
		getLastMonthDate() {          //戴卡上个月
			let date = new Date();
			let seperator1 = "-";
			let year = date.getFullYear();
			let month = date.getMonth() + 1;
			let strDate = date.getDate();
            let fixedData=26;
            let finalMonth=month;
            if(month== 1 && strDate<26){
                year=year-1;
                finalMonth=12;
            }
            if(strDate<26 && month !== 1){
                finalMonth=month-1
            }
			if (finalMonth >= 1 && finalMonth <= 9) {
				finalMonth = "0" + finalMonth;
			}
			if (fixedData >= 0 && fixedData <= 9) {
				fixedData = "0" + fixedData;
			}
			let currentdate = year + seperator1 + finalMonth + seperator1 + fixedData;
			return currentdate;
		},
		getCurrentMonthDate(){
			let date = new Date();
			let seperator1 = "-";
			let year = date.getFullYear();
			let month = date.getMonth() + 1;
			let strDate = date.getDate();
            let finalMonth=month;
            if(strDate>25){
                finalMonth=month+1;
            }
            if(month== 12 && strDate>25){
                year=year+1;
                finalMonth=1;
            }
			if (finalMonth >= 1 && finalMonth <= 9) {
				finalMonth = "0" + finalMonth;
			}
			let currentdate = year + seperator1 + finalMonth
			return currentdate;
		}
		
		
}



export default $api